package com.jinduplan.planmanager.mvp.presenter

import com.cxz.kotlin.baselibs.ext.ss
import com.cxz.kotlin.baselibs.mvp.BasePresenter
import com.jinduplan.planmanager.mvp.contract.ReportContract
import com.jinduplan.planmanager.mvp.model.ReportModel

/**
 * @author admin
 * @date 2018/11/20
 * @desc
 */
class ReportPresenter : BasePresenter<ReportContract.Model, ReportContract.View>(), ReportContract.Presenter {

    override fun createModel(): ReportContract.Model = ReportModel()
    override fun getReportList(page: String, limit: String) {
        mModel?.getReportList(page,limit)?.ss(mModel,mView,onSuccess = {
            mView?.refreshReportList(it.data)
        })
    }

    override fun getReportDetail(id: String) {

        mModel?.getReportDetail(id)?.ss(mModel,mView,onSuccess = {
            mView?.getDetail(it.data)
        })
    }

    override fun report(
        full_name: String,
        position: String,
        content: String,
        type: String,
        images: Array<String>
    ) {
        mModel?.report(full_name,position,content,type,images)?.ss(mModel,mView,onSuccess = {
            mView?.reportSuccess()
        },onError = {

        })
    }

    override fun uploadPics(pics: String) {
        mModel?.uploadPics(pics)?.ss(mModel,mView,onSuccess = {
            mView?.uploadSuccess(it.data.images)
        })
    }


}